home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / ncsat.cpt / Telnet2.5 final / main / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-14  |  16.6 KB  |  697 lines

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    config.c
  6. *    User interface code for NCSA Telnet for the Macintosh
  7. *     by Gaige B. Paulsen
  8. ****************************************************************************
  9. *                                                                          *
  10. *      Uses    :                                                               *
  11. *      TCP/IP kernel for NCSA Telnet                                       *
  12. *      by Tim Krauskopf                                                    *
  13. *       with Macintosh code by Gaige B. Paulsen                                 *
  14. *                                                                          *
  15. *      National Center for Supercomputing Applications                     *
  16. *      152 Computing Applications Building                                 *
  17. *      605 E. Springfield Ave.                                             *
  18. *      Champaign, IL  61820                                                *
  19. *                                                                          *
  20. *                                                                          *
  21. ****************************************************************************
  22. *
  23. *    Configuration structure and Set file functions.    
  24. *
  25. *    Called by:
  26. *        menu.c
  27. *        maclook.c
  28. */
  29.  
  30. #include <stdio.h>
  31. #include <ctype.h>
  32. #include <string.h>
  33.  
  34. #include <Dialogs.h>
  35. #include <Files.h>
  36. #include    <Fonts.h>
  37. #include <Memory.h>
  38. #include    <QuickDraw.h>
  39. #include    <SegLoad.h>
  40. #include <Strings.h>
  41. #include <prefs.h>
  42. #include    "configrec.h"
  43. #include "confile.h"
  44. #include "event.h"
  45. #include     "hostform.h" 
  46. #include "maclook.h"
  47. #include "menu.h"
  48. #include "netevent.h"
  49.  
  50. #ifdef MPW
  51. #include "mpw.h"
  52. #endif
  53.  
  54. extern int numwindows, whichMenus;
  55.  
  56. char *Cspace;
  57.  
  58. char *Ckeyw[] = {
  59.         "",                /* Skip so we start at one */
  60.         "name",            /* Name of session                **  1 **/
  61.         "host",            /* Name of host to use            **  2 **/
  62.         "size",            /* Window size (user)            **  3 **/
  63.         "scrollback",    /* Amount of scrollback            **  4 **/
  64.         "backspace",    /* set to backspace                **  5 **/
  65.         "delete",        /* set to delete                **  6 **/
  66.         "key0",            /* Macro definition key 0        **  7 **/
  67.         "key1",            /* Macro definition key 1        **  8 **/
  68.         "key2",            /* Macro definition key 2        **  9 **/
  69.         "key3",            /* Macro definition key 3        ** 10 **/
  70.         "key4",            /* Macro definition key 4        ** 11 **/
  71.         "key5",            /* Macro definition key 5        ** 12 **/
  72.         "key6",            /* Macro definition key 6        ** 13 **/
  73.         "key7",            /* Macro definition key 7        ** 14 **/
  74.         "key8",            /* Macro definition key 8        ** 15 **/
  75.         "key9",            /* Macro definition key 9        ** 16 **/
  76.         "commandkeys",    /* Command keys active?            ** 17 **/
  77.         "erase",        /* Erase mode (as in bs/del )      ** 18 **/
  78.         "width",        /* Width of the current session ** 19 **/
  79.         "tekclear",        /* Clear Tek for each drawing   ** 20 **/
  80.         "vtwidth",        /* Tim, I am going to hit you   ** 21 **/
  81.         "rgb0",            /* RGB Color #0                    ** 22 **/
  82.         "rgb1",            /* RGB Color #1                    ** 23 **/
  83.         "rgb2",            /* RGB Color #2                    ** 24 **/
  84.         "rgb3",            /* RGB Color #3                    ** 25 **/
  85.         "font",            /* Font for your window            ** 26 **/
  86.         "fsize",        /* Size for mr. font            ** 27 **/
  87.         "nlines",        /* number of active lines       ** 28 **/
  88.         "keystop",        /*  XOFF key                    ** 29 **/
  89.         "keygo",        /*  XON key                     ** 30 **/
  90.         "keyip",        /* interrupt process key        ** 31 **/
  91.         "crmap",        /* the CR mapping                ** 32 **/
  92.         "linemode",        /* allow line mode                ** 33 **/    /* BYU 2.4.9 */
  93.         "eightbit",        /* allow 8 bit font                ** 34 **/    /* BYU 2.4.9 */
  94.         "ftp",            /* ftp session                    ** 35 **/    /* BYU */
  95.         "serial",        /* serial port connection        ** 36 **/    /* BYU serial */
  96.         "port",            /* port number                     ** 37 **/    /* NCSA */
  97.         ""                /* END OF LIST */
  98.         };
  99. char *AffWords[]= {
  100.         "yes",
  101.         "y",
  102.         "on",
  103.         "active",
  104.         "true",
  105.         "alive",
  106.         "yup",
  107.         "yep",
  108.         "yessir",
  109.         "affirmative",
  110.         "ja",
  111.         ""
  112.         };
  113.  
  114.  
  115. #define PORTNUM 37            /* NCSA 2.5: the port variable */
  116.  
  117. int CONFstate=0,CONFactive=0;
  118. int position, inquote, lineno ;   /* state vars */    
  119. FILE *fp;
  120.  
  121. ConfigRec config;
  122.  
  123. int affirmative( s)
  124. char *s;
  125. {
  126.     int i;
  127.  
  128.     for (i=0; i<position; i++)
  129.         s[i] = tolower( s[i] );
  130.  
  131.     for (i=0;  *AffWords[i] && strcmp(AffWords[i],s); i++) ;
  132.     if (*AffWords[i])
  133.         return(1);
  134.     else
  135.         return(0);
  136. }
  137.  
  138. /* Prime the Configuration with Default Data (Capital D) */
  139. void configdefault
  140.   (
  141.     ConfigRec *config
  142.   )
  143. {
  144.     config->tektype =0;
  145.     config->bsdel=1;                        /* Default to Delete */
  146.     config->ftpwind =0;                        /* not an ftp window */
  147.     config->width=80;                        /*     "    "  "     "    */
  148.     config->ftpstate = 0;                    /* BYU - not at ftp session */
  149.     config->connectionType = 0;                /* BYU serial - not a serial port connection */
  150.     config->nlines=24;
  151.     config->tekclear=0;
  152.     config->clearsave=0;
  153.     config->halfdup=0;
  154.     config->crmap=0x0a;
  155.     config->vtwrap=0;
  156.     config->scrollback=120;                    /* Should be user defined */
  157.     config->machine="newton";                /* and host name pointer */
  158.     config->name="newton";                    /* and real name pointer */
  159.     config->port = 23;                        /* default is to use telnet port */
  160.     config->window.top   = config->stdwindow.top   = 40 +( numwindows *(5+Prefs.stag*15));
  161.     config->window.left  = config->stdwindow.left  = 5 +( numwindows *(5+Prefs.stag*15));
  162.     config->window.bottom= config->stdwindow.bottom=30000 +( numwindows *(5+Prefs.stag*15));
  163.     config->window.right = config->stdwindow.right =30000 +( numwindows *(5+Prefs.stag*15));
  164.     config->red[0]        =     0;
  165.     config->green[0]    =     0;
  166.     config->blue[0]        =     0;
  167.     config->red[1]        = 65535;
  168.     config->green[1]    = 65535;
  169.     config->blue[1]        = 65535;
  170.     config->red[2]        =     0;
  171.     config->green[2]    = 61183;
  172.     config->blue[2]        = 11060;
  173.     config->red[3]        = 61183;
  174.     config->green[3]    =  2079;
  175.     config->blue[3]        =  4938;
  176.     config->font        =     4;
  177.     config->fsize        =      9;
  178.     config->eightbit    =     1;    /* BYU 2.4.9 */
  179.     config->forcesave    =     0;    /* NCSA 2.5 */
  180.     config->TELstop        =    19;
  181.     config->TELgo        =    17;
  182.     config->TELip        =     3;
  183.     config->lineAllow    =     1;
  184. }
  185.  
  186. /* Prime the Configuration with real data.... */
  187. void primeConfig
  188.   (
  189.     ConfigRec *config
  190.   )
  191. {
  192.     struct machinfo *mp;
  193.     char s[255];
  194.  
  195.     mp = Shostlook( config->machine);
  196.     if (mp==NULL)
  197.         mp = Shostlook("default");
  198.     if (mp!= NULL) {
  199.         config->bsdel = mp->bksp == 127;
  200.         config->connectionType = 0;            /* BYU serial - not a serial port connection */
  201.         config->ftpstate = 0;                /* BYU - not at ftp session */
  202.         config->lineAllow = mp->linemode;    /* BYU 2.4.9 */
  203.         config->eightbit = mp->eightbit;    /* BYU 2.4.9 */
  204.         config->forcesave = mp->forcesave;    /* NCSA 2.5 */
  205.         config->width = mp->vtwidth;
  206.         config->tektype = mp->tektype;
  207.         config->nlines = mp->nlines;
  208.         config->tekclear=1;
  209.         config->clearsave = mp->clearsave;
  210.         config->halfdup = mp->halfdup;
  211.         config->crmap = mp->crmap;
  212.         config->scrollback = mp->bkscroll;
  213.         config->vtwrap = mp->vtwrap;
  214.         config->port = mp->port;
  215.         strcpy( s, mp->font);
  216.         getfnum( s, &config->font);
  217.         config->red[0]        = mp->nfcolor[0];
  218.         config->green[0]    = mp->nfcolor[1];
  219.         config->blue[0]        = mp->nfcolor[2];
  220.         config->red[1]        = mp->nbcolor[0];
  221.         config->green[1]    = mp->nbcolor[1];
  222.         config->blue[1]        = mp->nbcolor[2];
  223.         config->red[2]        = mp->bfcolor[0];
  224.         config->green[2]    = mp->bfcolor[1];
  225.         config->blue[2]        = mp->bfcolor[2];
  226.         config->red[3]        = mp->bbcolor[0];
  227.         config->green[3]    = mp->bbcolor[1];
  228.         config->blue[3]        = mp->bbcolor[2];
  229.         config->fsize        = mp->fsize;
  230.         config->TELstop        = mp->skey;
  231.         config->TELgo        = mp->qkey;
  232.         config->TELip        = mp->ckey;
  233.         config->window.top   = config->stdwindow.top   = 40 +( numwindows *(5+Prefs.stag*15));
  234.         config->window.left  = config->stdwindow.left  =  5 +( numwindows *(5+Prefs.stag*15));
  235.         config->window.bottom= config->stdwindow.bottom= 30000 +( numwindows *(5+Prefs.stag*15));
  236.         config->window.right = config->stdwindow.right = 30000 +( numwindows *(5+Prefs.stag*15));
  237.         }
  238.     else {
  239.         config->bsdel = 1;
  240.         config->width = 80;
  241.         config->nlines = 24;
  242.         config->tekclear=1;
  243.         config->clearsave=1;
  244.         config->connectionType = 0;            /* BYU serial - not a serial port connection */
  245.         config->ftpstate = 0;                /* BYU - not at ftp session */
  246.         config->halfdup = 0;
  247.         config->crmap = 0x0a;
  248.         config->scrollback = 120;
  249.         config->vtwrap = 0;
  250.         config->tektype = 0;
  251.     }
  252.  
  253.     if (config->width <2)
  254.         if (config->width ==0) 
  255.             config->width=80;
  256.         else config->width=132;
  257.         
  258.     if (config->TELip <= 0)
  259.         config->TELip = -1;        /* disable it */
  260.     if (config->TELstop <= 0)
  261.         config->TELstop = -1;        /* disable it */
  262.     if (config->TELgo <= 0)
  263.         config->TELgo = -1;        /* disable it */
  264. }
  265.  
  266. int confile
  267.   (
  268.     char *s
  269.   )
  270.   {
  271.     int i,scrn;
  272.     unsigned int a,b,c,d;
  273.  
  274.     putln(s);
  275.     if (!(*s) )
  276.         return(0);
  277.  
  278.     switch( CONFstate) {
  279.         case 0:                /* No keyword yet! */
  280.             for (i=0; i<position; i++)
  281.                 s[i] = tolower( s[i] );
  282.  
  283.             for (i=1;  *Ckeyw[i] && strcmp(Ckeyw[i],s); i++) ;
  284.  
  285.             if ( !(*Ckeyw[i]) ) {
  286.                 putln("ERROR IN KEYWORD!");
  287.                 putln(s);
  288.                 return(1);
  289.                 }
  290.  
  291.             CONFstate=i;
  292.  
  293.             if (CONFstate==5) {
  294.                 config.bsdel=0;
  295.                 CONFstate=0;
  296.                 }
  297.             if (CONFstate==6) {
  298.                 config.bsdel=1;
  299.                 CONFstate=0;
  300.                 }
  301.             break;
  302.  
  303.         case 1:                /* NAME */
  304.             putln("NAME");
  305.             { char *p;
  306.             if (NULL == ((Ptr) p = NewPtr(40000))) {
  307. #ifndef MPW
  308.                 OtherError("\PLoad Set Error:","\PNo space for machine name");
  309. #else
  310.                 OtherError("Load Set Error:","Not enough memory to open");
  311. #endif MPW
  312.                 return(-1);
  313.                 }
  314.             else
  315.                 DisposPtr(p);
  316.             }
  317.             if (CONFactive) {
  318.                 putln("Open attempt....");
  319.                 scrn=addport( &config );    /* Make our user window */
  320.                 if (scrn<0) {
  321.                     putln("ERROR IN OPENING!! ");
  322.                     return(42);
  323.                     }
  324.                 }
  325.  
  326.             configdefault( &config );                            /* Set up the defaults */
  327.             (Ptr) config.name = NewPtr( strlen( s) +2);            /* Allocate namespace */
  328.             strcpy(config.name, s);                                /* Move name in */
  329.             config.name= config.name;
  330.             CONFstate=0;
  331.             CONFactive=1;
  332.             break;
  333.  
  334.         case 2:
  335.             putln("HOST");
  336.             (Ptr) config.machine = NewPtr( strlen( s) +2);        /* Allocate namespace */
  337.             if (config.machine==NULL) {
  338. #ifndef MPW
  339.                 OtherError("\PLoad Set Error:","\PNo space for machine name");
  340. #else
  341.                 OtherError("Load Set Error:","No space for machine name");
  342. #endif MPW
  343.                 return(-1);
  344.                 }
  345.             strcpy(config.machine, s);                            /* Move name in */
  346.             primeConfig(&config);
  347.             CONFstate=0;
  348.             break;
  349.  
  350.         case 3:                /* SIZE */
  351.             putln("SIZE");
  352.             if ( 4 != sscanf(s, "{%d,%d,%d,%d}", &a, &b, &c,&d) ) {
  353.                 putln("Error in window size");
  354.                 return(2);
  355.                 }
  356.             
  357.             config.window.top=a;
  358.             config.window.left=b;
  359.             config.window.bottom=c;
  360.             config.window.right=d;
  361.             CONFstate=0;
  362.             break;
  363.  
  364.         case 4:
  365.             if ( 1 != sscanf(s,"%d", &a) ) {
  366.                 putln(" You need a parameter after Scrollback ");
  367.                 return(1);
  368.                 }
  369.             config.scrollback=a;
  370.             CONFstate=0;
  371.             break;
  372.  
  373.         case 5:
  374.             config.bsdel=0;
  375.             CONFstate=0;
  376.             break;
  377.  
  378.         case 6:
  379.             config.bsdel=1;
  380.             CONFstate=0;
  381.             break;
  382.  
  383.         case 7:
  384.             setmacro( 0, s);
  385.             CONFstate=0;
  386.             break;
  387.         case 8:
  388.             setmacro( 1, s);
  389.             CONFstate=0;
  390.             break;
  391.         case 9:
  392.             setmacro( 2, s);
  393.             CONFstate=0;
  394.             break;
  395.         case 10:
  396.             setmacro( 3, s);
  397.             CONFstate=0;
  398.             break;
  399.         case 11:
  400.             setmacro( 4, s);
  401.             CONFstate=0;
  402.             break;
  403.         case 12:
  404.             setmacro( 5, s);
  405.             CONFstate=0;
  406.             break;
  407.         case 13:
  408.             setmacro( 6, s);
  409.             CONFstate=0;
  410.             break;
  411.         case 14:
  412.             setmacro( 7, s);
  413.             CONFstate=0;
  414.             break;
  415.         case 15:
  416.             setmacro( 8, s);
  417.             CONFstate=0;
  418.             break;
  419.         case 16:
  420.             setmacro( 9, s);
  421.             CONFstate=0;
  422.             break;
  423.         case 17:
  424.             if (affirmative(s))
  425.                 whichMenus=1;
  426.             else
  427.                 whichMenus=0;
  428.             switchMenus(whichMenus);
  429.             CONFstate=0;
  430.             break;
  431.         case 18:
  432.             if (strcmp(s,"backspace") )
  433.                 config.bsdel=1;
  434.             else
  435.                 config.bsdel=0;
  436.             CONFstate=0;
  437.             break;
  438.         case 19:
  439.         case 21:
  440.             if ( 1 != sscanf(s,"%d", &a) ) {
  441.                 config.width=80;
  442.                 }
  443.             config.width=a;
  444.             CONFstate=0;
  445.             break;
  446.         case 20:
  447.             if (affirmative(s))
  448.                 config.tekclear = 1;
  449.             else
  450.                 config.tekclear = 0;
  451.             CONFstate = 0;
  452.             break;
  453.         case 22:
  454.         case 23:
  455.         case 24:
  456.         case 25:
  457.             if ( 3 != sscanf(s, "{%d,%d,%d}", &a, &b, &c)) {
  458.                 putln("Bad Parms to rgb");
  459.                 return(2);
  460.                 }
  461.             config.red[  CONFstate-22]     =a;
  462.             config.green[CONFstate-22]    =b;
  463.             config.blue[ CONFstate-22]    =c;
  464.             CONFstate = 0;
  465.             break;
  466.         case 26:        /* Font Name */
  467. #ifndef MPW
  468.             ctop(s);
  469. #endif MPW
  470.             getfnum( s, &config.font);
  471.             CONFstate = 0;
  472.             break;
  473.         case 27:        /* Font Size */
  474.             if (1 == sscanf( s, "%d", &a))
  475.                 config.fsize=a;
  476.             CONFstate = 0;
  477.             break;
  478.         case 28:        /* number of lines to use for window's editable region */
  479.             if (1 == sscanf( s, "%d", &a))
  480.                 config.nlines=a;
  481.             CONFstate = 0;
  482.             break;
  483.         case 29:        /* keystop, XOFF key */
  484.             if (1 == sscanf( s, "%d", &a))
  485.                 config.TELstop=a;
  486.             CONFstate = 0;
  487.             break;
  488.         case 30:        /* keygo, XON key */
  489.             if (1 == sscanf( s, "%d", &a))
  490.                 config.TELgo=a;
  491.             CONFstate = 0;
  492.             break;
  493.         case 31:        /* keyip, kill key */
  494.             if (1 == sscanf( s, "%d", &a))
  495.                 config.TELip=a;
  496.             CONFstate = 0;
  497.             break;
  498.         case 32:        /* cr-map */
  499.             putln("got crmap");
  500.             if (1 == sscanf( s, "%d", &a))
  501.                 config.crmap=a;
  502.             CONFstate = 0;
  503.             break;
  504.         case 33:                    /* BYU 2.4.9 */
  505.             if (affirmative(s))        /* BYU 2.4.9 */
  506.                 config.lineAllow=1;    /* BYU 2.4.9 */
  507.             else                    /* BYU 2.4.9 */
  508.                 config.lineAllow=0;    /* BYU 2.4.9 */
  509.             CONFstate=0;            /* BYU 2.4.9 */
  510.             break;                    /* BYU 2.4.9 */
  511.         case 34:                    /* BYU 2.4.9 */
  512.             if (affirmative(s))        /* BYU 2.4.9 */
  513.                 config.eightbit=1;    /* BYU 2.4.9 */
  514.             else                    /* BYU 2.4.9 */
  515.                 config.eightbit=0;    /* BYU 2.4.9 */
  516.             CONFstate=0;            /* BYU 2.4.9 */
  517.             break;                    /* BYU 2.4.9 */
  518.         case 35:                    /* BYU */
  519.             config.ftpstate=1;        /* BYU */
  520.             CONFstate=0;            /* BYU */
  521.             break;                    /* BYU */
  522.         case 36:                    /* BYU serial */
  523.             config.connectionType=1;/* BYU serial */
  524.             CONFstate=0;            /* BYU serial */
  525.             break;                    /* BYU serial */
  526.         case PORTNUM:                                /* NCSA 2.5: get the real port # */
  527.             if (1 == sscanf( s, "%d", &a))        /* NCSA */
  528.                 config.port=a;                    /* NCSA */
  529.             CONFstate = 0;                        /* NCSA */
  530.             break;                                /* NCSA */
  531.         default:
  532.             putln("I'm so stateless....");
  533.             CONFstate=0;
  534.         }
  535.     return(0);
  536.   } /* confile */
  537.  
  538. /************************************************************************/
  539. /* Scontoken
  540. *  tokenize the strings which get passed to Sconfile.
  541. *  Handles quotes and uses separators:  <33, ;:=
  542. */ 
  543. int contoken
  544.   (
  545.     int c
  546.   )
  547.     {
  548.     int retval,scrn;
  549.  
  550.     if (c == EOF) {
  551.         Cspace[position++] = '\0';
  552.         putln("Eof handler called");
  553.         confile(Cspace);
  554.         if (CONFactive) {
  555.                 putln("attempting open");
  556.                 scrn=addport( &config );    /* Make our user window */
  557.                 if (scrn<0) {
  558.                     putln("ERROR IN OPENING!! ");
  559.                     return(42);
  560.                     }
  561.                 }
  562.         return(-1);
  563.     }
  564.     
  565.     if (!position && !inquote && Sissep(c))
  566.     /*if (!position && Sissep(c))    */    /* old_skip over junk before keyword */
  567.         return(0);
  568.  
  569.     if (inquote || !Sissep(c)) {
  570.  
  571.         if (position > 200) {
  572.             putln("Out of bounds error!");
  573.             return(1);
  574.         }
  575. /*
  576. *  check for quotes, a little mixed up here, could be reorganized
  577. */
  578.         if (c == '"' ) {
  579.             if (!inquote) {            /* beginning of quotes */
  580.                 inquote = 1;
  581.                 return(0);
  582.             }
  583.              Cspace[position++] =c;
  584.             return(0);
  585.         }
  586.         else 
  587.             {                        /* include in current string */
  588.             if (c != '\n')
  589.                 {
  590.                 Cspace[position++] = c;
  591.                 return(0);
  592.                 }
  593.             }
  594.                 
  595.         }
  596.  
  597.     if (Cspace[position-1] == '"') position--;
  598.     Cspace[position++] = '\0';
  599.  
  600.     retval = confile(Cspace);            /* pass the token along */
  601.  
  602.     position = 0;
  603.     inquote = 0;
  604.     Cspace[0] = '\0';
  605.  
  606.     return(retval);
  607. }
  608.  
  609. /************************************************************************/
  610. /*  Sreadhosts
  611. *   read in the hosts file into our in-memory data structure.
  612. *   Handle everything by keyword, see docs for specifications about file.
  613. */
  614. int readconfig
  615.   (
  616.     char *Cfile
  617.   )
  618. {
  619.     int c,retval;
  620.  
  621.     (Ptr) Cspace = NewPtr(256);                /* get room for gathering stuff */
  622.  
  623.     configdefault(&config);
  624.  
  625.     if (NULL == Cspace) {
  626. #ifndef MPW
  627.         OtherError("\PNo space for set to load","\P ");
  628. #else
  629.         OtherError("No space for set to load"," ");
  630. #endif MPW
  631.         return(1);
  632.         }
  633.     
  634.     position = CONFstate = CONFactive = inquote = lineno = 0;   /* state vars */    
  635.  
  636.     if (NULL == (fp = fopen(Cfile,"r"))) {
  637.         putln("Couldn't open Configuration file:");
  638.         putln( Cfile);
  639.         return(1);
  640.     }
  641.  
  642.     retval = 0;
  643.     while (!retval) {
  644.         c = fgetc(fp);
  645.         if (c == '#' && !inquote) {
  646.             while (c != EOF && c != '\n')        /* skip to EOL */
  647.                 c = fgetc(fp);
  648.         }
  649.         if (c == '\n')
  650.             lineno++;
  651.         retval = contoken(c);
  652.     }
  653.  
  654.     fclose(fp);
  655.     DisposPtr((Ptr) Cspace);
  656.  
  657.     if (retval == EOF) {                /* EOF is normal end */
  658.         putln("EOF termination");
  659.         return(0);
  660.         }
  661.     else {
  662.         putln("NON-EOF termination");
  663.         return(retval);
  664.         }
  665. }
  666.  
  667. /*
  668.  * checkCONF - check if the user clicked on a configuration file
  669.  */
  670.  
  671. int checkCONF
  672.   (
  673.     void
  674.   )
  675. {
  676.     short i,mess,count,retcode=0;
  677.     AppFile theFile;
  678.  
  679.     CountAppFiles(&mess,&count);
  680.     if (mess==1) { putln("PRINTING...."); return(FALSE); }
  681.     if (count<1) { putln("No files (<1)"); return(FALSE); }
  682.     for(i=1;i<=count;i++) {
  683.         GetAppFiles(i, &theFile);
  684.         if (theFile.fType=='CONF') {
  685.             ClrAppFiles(i);
  686.             setvol( 0L, theFile.vRefNum);
  687.             p2cstr( &theFile.fName);
  688.             readconfig( &theFile.fName);
  689.             putln("file has been read");
  690.             retcode=1;
  691.             }
  692.         }
  693.     return(retcode);
  694. }
  695.  
  696.  
  697.